import { COMMAND_STATUS } from "@/FrontProcessing/interface";
import { System } from "@/FrontProcessing/System/System";
import { v4 as uuid } from "uuid";
import { API_EVENT } from "@/FrontProcessing/interface/api.interface";
import { devtool } from "cax-base";

export abstract class BaseCommand {
  readonly id: string = uuid();
  status: COMMAND_STATUS = COMMAND_STATUS.BEGIN;
  system: System;
  params: any;
  abstract event: API_EVENT;

  constructor(system: System, params: any) {
    this.system = system;
    this.params = params;
  }

  abstract execute(): any;

  abstract undo(): any;

  log() {
    devtool.success(this.event, this.params);
  }
}
